﻿using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
using StudentAgeSaveEditor.SaveData;
using System.Diagnostics;

namespace StudentAgeSaveEditor.ViewModel
{
    partial class MainViewModel : ObservableObject
    {
    
        [ObservableProperty]
        public BagTableViewModel bagTableViewModel;
        [ObservableProperty]
        string fileName ="aaaa";
        public IRelayCommand LoadData { get; }
        public MainViewModel()
        {
            this.BagTableViewModel = new BagTableViewModel();
            LoadData = new RelayCommand(Load);
        }

      
        public void Load()
        {
            Test();
        }

        private void Test()
        {
            string dic = "H:\\C#\\StudentAgeSaveEditor\\TestData\\";
            string filename = "无名.200621.638421646721373516.save";
            (var s, var ans) = DataMrg.Load(dic, filename);
            if (!ans)
            {
                Debug.Write("Not Find file");
            }
            else
            {
                if(s.bagModel!=null)
                BagTableViewModel.Init(ref s.bagModel);
            }
        }
        [RelayCommand]
        private void ShowBag()
        {

        }
    }
}
